#include <stdio.h>
#include <assert.h>

int leftmost_one(unsigned int x){
    x |= x >> 1;
    x |= x >> 2;
    x |= x >> 4;
    x |= x >> 8;
    x |= x >> 16;

    return (x >> 1) + (x && 1);
}

int main(){

    assert(leftmost_one(0x01100001) == 0x01000000);
    assert(leftmost_one(0x0) == 0);

    return 0;
}
